<!doctype html>
<html lang="en">
<head>
    <!-- Required meta tags -->
    <meta charset="utf-8">
    <meta content="width=device-width, initial-scale=1, shrink-to-fit=no" name="viewport">
    <title>Login</title>
    <link href="css/bootstrap.min.css" rel="stylesheet">
    <script src="js/jquery-3.5.1.min.js"></script>
    <script src="js/bootstrap.bundle.min.js"></script>
</head>
<body>
<br>
<div align="center">
    <table>
        <tr>
            <td>邮箱：</td>
            <td><label><input name="email" type="text" id="email"/></label></td>
        </tr>
        <tr>
            <td>密码：</td>
            <td><label><input name="password" type="password" id="password"/></label></td>
        </tr>
    </table>
    <button class="btn btn-primary" id="submit" type="submit">登录</button>
    <br>
    <br>
    <a href="register.html" class="card-link">注册新账号</a>
</div>
</body>
<script type="text/javascript">
    $(function () {
        $('#submit').click(function () {
            var email = $('#email').val();
            var password = $('#password').val();
            if( email == "" || password == "" ){
                alert("请输入邮箱和密码");
                return;
            }
            $.ajax({
                method: "POST",
                url: 'http://www.test.com/api/user/login/' + email+ '/' + password,
                data: {}
            }).done(function (data, textStatus) {
                if( data.status != 0 ){
                    alert(data.message);
                } else {
                    window.location.replace("http://www.test.com/static/welcome.html");
                }
            }).fail(function (jqXHR, textStatus) {
                alert("Request failed: " + jqXHR.statusText);
            })
        })

    });
</script>
</html>